package qeb.handheldmedical.patient;

import qeb.handheldmedical.R;
import qeb.handheldmedical.model.InPatient;
import qeb.handheldmedical.model.User;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

/**
 * @author 作者(dugaoyi) E-mail:dugaoyi@163.com
 * @version 创建时间：2016年10月17日 下午7:51:43
 * @declaration 患者主界面
 */
public class PatientMain extends Activity {
	InPatient pi = new InPatient();
	private User usr;
	private Button btnhzxx, btnjcbg, btnjybg, btnyzcq, btnyzls, btnsmtz,
			btnYzCheck, btnssjl, btnhzjl, btnxtjl, btnryjl;
	private Button btn_title_back, btn_title_right;
	private TextView tv_title;

	/*
	 * (non-Javadoc)
	 * 
	 * @see android.app.Activity#onCreate(android.os.Bundle)
	 */
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		super.onCreate(savedInstanceState);
		setContentView(R.layout.patient_main);
		usr = (User) getIntent().getSerializableExtra("userinfo");
		pi = (InPatient) getIntent().getSerializableExtra("patientInfo");
		initUI();
	}

	/**
	 * 加载界页
	 */
	private void initUI() {
		// TODO Auto-generated method stub
		tv_title = (TextView) findViewById(R.id.tv_top_title);
		tv_title.setText(pi.XM);
		btn_title_back = (Button) findViewById(R.id.btn_title_back);
		btn_title_back.setOnClickListener(MyOnClickListener);

		btnhzxx = (Button) findViewById(R.id.btnhzxx);
		btnhzxx.setOnClickListener(MyOnClickListener);

		btnjcbg = (Button) findViewById(R.id.btnjcbg);
		btnjcbg.setOnClickListener(MyOnClickListener);

		btnjybg = (Button) findViewById(R.id.btnjybg);
		btnjybg.setOnClickListener(MyOnClickListener);

		btnyzcq = (Button) findViewById(R.id.btnyzcq);
		btnyzcq.setOnClickListener(MyOnClickListener);

		btnyzls = (Button) findViewById(R.id.btnyzls);
		btnyzls.setOnClickListener(MyOnClickListener);

		btnsmtz = (Button) findViewById(R.id.btnsmtz);
		btnsmtz.setOnClickListener(MyOnClickListener);

		btnssjl = (Button) findViewById(R.id.btnssjl);
		btnssjl.setOnClickListener(MyOnClickListener);

		btnhzjl = (Button) findViewById(R.id.btnhzjl);
		btnhzjl.setOnClickListener(MyOnClickListener);

		btnxtjl = (Button) findViewById(R.id.btnxtjl);
		btnxtjl.setOnClickListener(MyOnClickListener);

		btnryjl = (Button) findViewById(R.id.btnryjl);
		btnryjl.setOnClickListener(MyOnClickListener);
		btnYzCheck = (Button) findViewById(R.id.btnYzCheck);
		btnYzCheck.setOnClickListener(MyOnClickListener);
	}

	private OnClickListener MyOnClickListener = new OnClickListener() {
		@Override
		public void onClick(View v) {
			// TODO 自动生成的方法存根
			// Bundle bundle=new Bundle();
			Intent intent;
			switch (v.getId()) {
			case R.id.btn_title_back:// 返回按钮
				PatientMain.this.finish();
				break;

			case R.id.btnxtjl:// 病人血糖图片按钮
				intent = new Intent(PatientMain.this,
						qeb.handheldmedical.patient.BloodSugarList.class);
				intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				intent.putExtra("patientinfo", pi);
				intent.putExtra("userinfo", usr);
				PatientMain.this.getApplicationContext().startActivity(intent);
				break;
			case R.id.btnjcbg:// 检查报告图片按钮
				intent = new Intent(PatientMain.this,
						qeb.handheldmedical.patient.PacsQuery.class);
				intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				intent.putExtra("patientinfo", pi);
				PatientMain.this.getApplicationContext().startActivity(intent);
				break;
			case R.id.btnsmtz:// 生命体征
				intent = new Intent(PatientMain.this,
						qeb.handheldmedical.patient.Temperature.class);
				intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				intent.putExtra("patientinfo", pi);
				intent.putExtra("userinfo", usr);
				PatientMain.this.getApplicationContext().startActivity(intent);
				break;
			case R.id.btnjybg:// 检验报告
				intent = new Intent(PatientMain.this,
						qeb.handheldmedical.patient.LisQuery.class);
				intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				intent.putExtra("patientinfo", pi);
				PatientMain.this.getApplicationContext().startActivity(intent);
				break;
			case R.id.btnssjl:// 手术记录
				intent = new Intent(PatientMain.this,
						qeb.handheldmedical.patient.OperationList.class);
				intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				intent.putExtra("patientinfo", pi);
				PatientMain.this.getApplicationContext().startActivity(intent);
				break;
			case R.id.btnhzjl:// 会诊记录
				intent = new Intent(PatientMain.this,
						qeb.handheldmedical.patient.ConsultationQQList.class);
				intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				intent.putExtra("patientinfo", pi);
				PatientMain.this.getApplicationContext().startActivity(intent);
				break;
			case R.id.btnhzxx:// 患者信息
				intent = new Intent(PatientMain.this,
						qeb.handheldmedical.patient.InpatientInfo.class);
				intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				intent.putExtra("patientinfo", pi);
				PatientMain.this.getApplicationContext().startActivity(intent);
				break;
			case R.id.btnryjl:// 入院记录
				final Intent intent_ryjl = new Intent(PatientMain.this,
						qeb.handheldmedical.patient.PatientRyjl.class);
				intent_ryjl.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				intent_ryjl.putExtra("patientinfo", pi);
				PatientMain.this.getApplicationContext().startActivity(
						intent_ryjl);
				break;
			case R.id.btnyzcq:// 长期医嘱
				intent = new Intent(PatientMain.this,
						qeb.handheldmedical.instruction.Instruction.class);
				intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				intent.putExtra("patientinfo", pi);
				intent.putExtra("yzlx", "0");
				PatientMain.this.getApplicationContext().startActivity(intent);
				break;
			case R.id.btnyzls:// 临时医嘱
				intent = new Intent(PatientMain.this,
						qeb.handheldmedical.instruction.Instruction.class);
				intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				intent.putExtra("patientinfo", pi);
				intent.putExtra("yzlx", "1");
				PatientMain.this.getApplicationContext().startActivity(intent);
				break;

			case R.id.btnYzCheck:// 医嘱核对
				intent = new Intent(PatientMain.this,
						qeb.handheldmedical.instruction.CheckInstruction.class);
				intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				intent.putExtra("patientinfo", pi);
				intent.putExtra("userinfo", usr);
				intent.putExtra("ly", "1");
				PatientMain.this.getApplicationContext().startActivity(intent);
				break;
			default:
				break;
			}
		}
	};
}
